package com.gdglc.spring.biz.impl.auth;

import java.util.Date;
import java.util.List;

import com.gdglc.spring.biz.auth.RoleauthorityBiz;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.y2.authprj.bean.auth.model.RoleauthorityInfo;
import com.y2.authprj.bean.auth.model.StaffInfo;
import com.y2.authprj.dao.auth.IRoleauthorityDao;
import com.y2.authprj.exception.BizException;

public class RoleauthorityBizImpl implements RoleauthorityBiz{
	private IRoleauthorityDao dao;
	

	public IRoleauthorityDao getDao() {
		return dao;
	}


	public void setDao(IRoleauthorityDao dao) {
		this.dao = dao;
	}



	public void add(RoleauthorityInfo roleauthority) throws BizException {
		roleauthority.setDeleteFlag(1);
		roleauthority.setCreatetTime(new Date());
		try{
			dao.add(roleauthority);
		}catch(Exception e){
			throw new BizException("添加失败",e);
		}

		
	}

	public int deleteRole(int roleauthorityId) {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<RoleauthorityInfo> queryByChose(RoleauthorityInfo roleauthority) {
		return dao.queryByChose(roleauthority);
	}

	public PageInfo<RoleauthorityInfo> queryByPage(RoleauthorityInfo roleauthority, Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null?1:pageNo;//当前页  *必须
	    pageSize = pageSize == null?10:pageSize;//每页的数量* 必须
	    PageHelper.startPage(pageNo, pageSize);//*必须
	    List<RoleauthorityInfo> list = dao.queryByChose(roleauthority);
	    PageInfo<RoleauthorityInfo> page = new PageInfo<RoleauthorityInfo>(list);
	    return page;
	}

}
